package com.yc.auction.dao.impl;

import java.io.IOException;
import java.util.List;
import org.apache.ibatis.session.SqlSession;
import com.yc.auction.dao.DBAccess;
import com.yc.auction.dao.IBidInfoDao;
import com.yc.auction.entity.BidInfo;

public class BidInfoDaoImpl implements IBidInfoDao{
	private DBAccess db=new DBAccess();
	private SqlSession session;
	
	public int add(BidInfo bidInfo) {
		int result=0;
		try {
			session=db.getSqlSession();
			result=session.insert("BidInfoDao.add",bidInfo);
			session.commit();
		} catch (IOException e) {
			session.rollback();
			e.printStackTrace();
		} finally{
			if(session!=null){
				session.close();
			}
		}
		return result;
	}

	public List<BidInfo> find(BidInfo bidInfo) {
		List<BidInfo> list=null;
		try {
			session=db.getSqlSession();
			list=session.selectList("BidInfoDao.find",bidInfo);
		} catch (IOException e) {
			e.printStackTrace();
		} finally{
			if(session!=null){
				session.close();
			}
		}
		return list;
	}
}
